package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Actentry;
import com.ruoyi.system.service.IActentryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动报名Controller
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Controller
@RequestMapping("/system/actentry")
public class ActentryController extends BaseController
{
    private String prefix = "system/actentry";

    @Autowired
    private IActentryService actentryService;

    @RequiresPermissions("system:actentry:view")
    @GetMapping()
    public String actentry()
    {
        return prefix + "/actentry";
    }

    /**
     * 查询活动报名列表
     */
    @RequiresPermissions("system:actentry:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Actentry actentry)
    {
        startPage();
        List<Actentry> list = actentryService.selectActentryList(actentry);
        return getDataTable(list);
    }

    /**
     * 导出活动报名列表
     */
    @RequiresPermissions("system:actentry:export")
    @Log(title = "活动报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Actentry actentry)
    {
        List<Actentry> list = actentryService.selectActentryList(actentry);
        ExcelUtil<Actentry> util = new ExcelUtil<Actentry>(Actentry.class);
        return util.exportExcel(list, "活动报名数据");
    }

    /**
     * 新增活动报名
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动报名
     */
    @RequiresPermissions("system:actentry:add")
    @Log(title = "活动报名", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Actentry actentry)
    {
        return toAjax(actentryService.insertActentry(actentry));
    }

    /**
     * 修改活动报名
     */
    @RequiresPermissions("system:actentry:edit")
    @GetMapping("/edit/{actentryId}")
    public String edit(@PathVariable("actentryId") Long actentryId, ModelMap mmap)
    {
        Actentry actentry = actentryService.selectActentryByActentryId(actentryId);
        mmap.put("actentry", actentry);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动报名
     */
    @RequiresPermissions("system:actentry:edit")
    @Log(title = "活动报名", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Actentry actentry)
    {
        return toAjax(actentryService.updateActentry(actentry));
    }

    /**
     * 删除活动报名
     */
    @RequiresPermissions("system:actentry:remove")
    @Log(title = "活动报名", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actentryService.deleteActentryByActentryIds(ids));
    }
}
